//src/main/java/com/ruoyi/system/ai/controller/ChatSseController.java

package com.ruoyi.znjc.ai.controller;

import com.ruoyi.znjc.ai.model.ChatRequest;
import com.ruoyi.znjc.ai.service.ChatSseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@RestController
@RequestMapping("/api/ai/sse")
public class ChatSseController {

    @Autowired
    private ChatSseService chatSseService;

    @PostMapping("/chat")
    public SseEmitter chat(@RequestBody ChatRequest request) {
        return chatSseService.chat(request.getQuestion(), request.getConversationId());
    }
}
